<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="__PUBLIC__/js/jquery-easyui-1.5.1/themes/default/easyui.css">
    <link rel="stylesheet" href="__PUBLIC__/js/jquery-easyui-1.5.1/themes/icon.css">

    <script src="__PUBLIC__/js/jquery-easyui-1.5.1/jquery.min.js"></script>
    <script src="__PUBLIC__/js/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
    <script src="__PUBLIC__/js/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
    <script src="__PUBLIC__/js/jquery-easyui-1.5.1/plugins/jquery.layout.js"></script>
    <script src="__PUBLIC__/JS/Highcharts-5.0.10/code/highcharts.js"></script>


    <script>

        function SetWeek1(){
            var now=new Date();
            var week1 = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7, 0, 0, 0);
            week1 = new Date(now.getTime()-1000*60*60*24*7);

           Settime(week1,now);
        }
        function Setmonth1(){
            var now=new Date();
            var week1 = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate(), 0, 0, 0);
            Settime(week1,now);
        }
        function Setmonth3(){
            var now=new Date();
            var week1 = new Date(now.getFullYear(), now.getMonth() - 3, now.getDate(), 0, 0, 0);
            Settime(week1,now);
        }
        function Setmonth6(){
            var now=new Date();
            var week1 = new Date(now.getFullYear(), now.getMonth() - 6, now.getDate(), 0, 0, 0);
            Settime(week1,now);
        }
        function Setmonth12(){
            var now=new Date();
            var week1 = new Date(now.getFullYear(), now.getMonth() - 12, now.getDate(), 0, 0, 0);
            Settime(week1,now);
        }
        function Settime(stime,dtime){

            stime=stime.getFullYear()+'-'+(stime.getMonth()+1)+'-'+stime.getDate()+' ';//擦,js的月份是从0开始的
            dtime=dtime.getFullYear()+'-'+(dtime.getMonth()+1)+'-'+dtime.getDate()+' 23:59:0';//擦,js的月份是从0开始的
            $('#stime').datetimebox('setValue',stime.toLocaleString());
            $('#dtime').datetimebox('setValue',dtime.toLocaleString());
            doserach();
        }
        function doserach() {
            $('#dg').datagrid('reload',{
                stime:$('#stime').datetimebox('getValue'),
                dtime:$('#dtime').datetimebox('getValue')
            });
            $('#gx').datagrid('reload', {
                stime: $('#stime').datetimebox('getValue'),
                dtime: $('#dtime').datetimebox('getValue')
            });
        }
    </script>
    <script>
        $(function () {
                 $('#dg').datagrid({
                striped:true,
                     title: '工时统计',
                checkOnSelect:false,
                     width:'500px',
                url:"{:U('home/gsvalue/getlist')}",
                columns:[[

                    {field:'name',title:'名称',width:100},
                    {field:'gsvalue',title:'工时',width:100,align:'right',
                    formatter:function (value) {
                            if(!value){
                                return 0;
                            }else {
                                var num = Number(value);
                                return num.toFixed(2);
                            }
                    }
                    }
                ]]
            });

            $('#gx').datagrid({
                striped: true,
                title: '休假加班统计',
                checkOnSelect: false,
                width: '500px',
                url: "{:U('home/leave/getsumlist')}",
                columns: [[

                    {field: 'name', title: '名称', width: 100},
                    {
                        field: 'jiaban', title: '加班', width: 100, align: 'right',
                        formatter: function (value) {
                            if (!value) {
                                return 0;
                            } else {
                                var num = Number(value / 2);
                                return num.toFixed(2);
                            }
                        }
                    },
                    {
                        field: 'qingjia', title: '加班', width: 100, align: 'right',
                        formatter: function (value) {
                            if (!value) {
                                return 0;
                            } else {
                                var num = Number(value / 2);
                                return num.toFixed(2);
                            }
                        }
                    }
                ]]
            });

            Setmonth1();
        })
    </script>
    <title>图表界面</title>


</head>
<body>
图表界面
<br>
<div>
      <span>
         <span>开始时间</span>
    <input id="stime" class="easyui-datetimebox"  style="line-height:26px;border:1px solid #ccc">
    <span>结束时间</span>
    <input id="dtime" class="easyui-datetimebox"  style="line-height:26px;border:1px solid #ccc">
    </span>
    <a id="btn_ser" href="#" class="easyui-linkbutton" onclick="doserach()" data-options="iconCls:'icon-search'">搜索</a>
    <br>
    <a id="week1" href="#" class="easyui-linkbutton" onclick="SetWeek1()" data-options="iconCls:'icon-search'">近一周</a>
    <a id="month1" href="#" class="easyui-linkbutton" onclick="Setmonth1()" data-options="iconCls:'icon-search'">近一个月</a>
    <a id="month3" href="#" class="easyui-linkbutton" onclick="Setmonth3()" data-options="iconCls:'icon-search'">近三个月</a>
    <a id="month6" href="#" class="easyui-linkbutton" onclick="Setmonth6()" data-options="iconCls:'icon-search'">近六个月</a>
    <a id="month12" href="#" class="easyui-linkbutton" onclick="Setmonth12()" data-options="iconCls:'icon-search'">近一年</a>
    <div>
        <table id="dg"></table>
    </div>
    <div>
        <table id="gx"></table>
    </div>
</div>

</body>
</html>